import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// setup使用name的插件
import VueSetupExtend from 'vite-plugin-vue-setup-extend'
// 需要yarn add @types/node -D
const path = require('path')

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(), VueSetupExtend()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src')
    }
  },
  // 配置style的loader 自动导入项目中的less变量和混入函数mixins
  css: {
    preprocessorOptions: {
      less: {
        additionalData: `
          @import '@/assets/styles/variables.less';
          @import '@/assets/styles/mixins.less';
        `
      }
    }
  },
  server: {
    port: 8080,
    host: 'www.corho.com',
    open: true,
    cors: true // 允许ajax跨域
  }
})
